package com.xz.disk.utils;

import lombok.Data;

/**
 * @program: Official
 * @description: 返回结果
 * @author: Shawn
 * @create: 2019-11-13 10:21
 **/
@Data
public class ResponseResult {
    private Integer code;
    private String msg;
    private Object data;

    public static ResponseResult MESSAGE(ResCode code,String msg){
        return new ResponseResult(code.getIndex(),msg,null);
    }
    public static ResponseResult SUCCESS(){
        return new ResponseResult(ResCode.SUCCESS.getIndex(),"",null);
    }
    public static ResponseResult SUCCESS(String msg){
        return new ResponseResult(ResCode.SUCCESS.getIndex(),msg,null);
    }
    public static ResponseResult SUCCESS(Object data){
        return new ResponseResult(ResCode.SUCCESS.getIndex(),"",data);
    }
    public static ResponseResult SUCCESS(String msg,Object data){
        return new ResponseResult(ResCode.SUCCESS.getIndex(),msg,data);
    }

    public static ResponseResult FAIL(){
        return new ResponseResult(ResCode.ERROR.getIndex(),"",null);
    }
    public static ResponseResult FAIL(String msg){
        return new ResponseResult(ResCode.ERROR.getIndex(),msg,null);
    }
    public static ResponseResult ERROR(String msg){
        return new ResponseResult(ResCode.ERROR.getIndex(),msg,null);
    }
    public static ResponseResult ERROR(){
        return new ResponseResult(ResCode.ERROR.getIndex(),"请求失败",null);
    }
    private ResponseResult(){}
    public ResponseResult(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

}
